package com.ruoyi;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @Author syc
 * @Date Created in 11:17 2022/8/23
 * @Description 测试JUC安全类型的集合
 */
public class TestJUC {
    /**
     * @Author syc
     * @Date Created in 2022-08-23 11:21:59
     * @Description
     */
    public static void main(String[] args) {
        CopyOnWriteArrayList list = new CopyOnWriteArrayList();
        for (int i = 0; i < 10000; i++) {
            new Thread(()->{
                list.add(Thread.currentThread().getName());
            }).start();
        }
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(list.size());
    }
}
